/**
 * @author 李民康
 * @date 2024/12/4 16:47:17
 */
import java.math.BigDecimal;

public class ShoppingCart {
    private Fruit apple;
    private Fruit strawberry;
    private Fruit mango;

    public ShoppingCart() {
        // 初始化水果对象，超市的价格不变
        apple = new Fruit("Apple", new BigDecimal("8.0"));
        strawberry = new Fruit("Strawberry", new BigDecimal("13.0"));
        mango = new Fruit("Mango", new BigDecimal("20.0"));
    }

    // 计算顾客 A 的总价（只考虑苹果和草莓）
    public BigDecimal calculateTotalPriceA(int appleKg, int strawberryKg) {
        BigDecimal total = BigDecimal.ZERO;
        total = total.add(apple.getTotalPrice(appleKg));
        total = total.add(strawberry.getTotalPrice(strawberryKg));
        return total;
    }

    // 计算顾客 B 的总价（考虑苹果、草莓和芒果）
    public BigDecimal calculateTotalPriceB(int appleKg, int strawberryKg, int mangoKg) {
        BigDecimal total = BigDecimal.ZERO;
        total = total.add(apple.getTotalPrice(appleKg));
        total = total.add(strawberry.getTotalPrice(strawberryKg));
        total = total.add(mango.getTotalPrice(mangoKg));
        return total;
    }

    // 计算顾客 C 的总价（草莓打 8 折）
    public BigDecimal calculateTotalPriceC(int appleKg, int strawberryKg, int mangoKg) {
        BigDecimal total = BigDecimal.ZERO;
        total = total.add(apple.getTotalPrice(appleKg));
        total = total.add(strawberry.getTotalPrice(strawberryKg).multiply(new BigDecimal("0.8"))); // 草莓打 8 折
        total = total.add(mango.getTotalPrice(mangoKg));
        return total;
    }

    // 计算顾客 D 的总价（购物满 100 减 10）
    public BigDecimal calculateTotalPriceD(int appleKg, int strawberryKg, int mangoKg) {
        BigDecimal total = BigDecimal.ZERO;
        total = total.add(apple.getTotalPrice(appleKg));
        total = total.add(strawberry.getTotalPrice(strawberryKg));
        total = total.add(mango.getTotalPrice(mangoKg));

        // 如果总价大于等于 100，减去 10
        if (total.compareTo(new BigDecimal("100")) >= 0) {
            total = total.subtract(new BigDecimal("10"));
        }

        return total;
    }
}
